package com.lele.controller;

import javax.servlet.ServletConfig;
import javax.servlet.ServletContext;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebInitParam;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

// 使用注解的方法代替xml里注册servlet和设置初始化的参数的配置
@WebServlet(urlPatterns = {"/as"}, initParams = {@WebInitParam(name = "asKey", value = "asValue")})
public class AnnotationServlet extends HttpServlet {
    @Override
    public void init() throws ServletException {
        ServletConfig config = getServletConfig();
        String str = config.getInitParameter("asKey");
        System.out.println(str);

        ServletContext application = getServletContext();
        System.out.println(application.getInitParameter("cname"));
    }

    @Override
    protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {

    }
}
